<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="layui/css/layui.css"/>
		<script src="layui/layui.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<form class="layui-form" action="">
			<input type="hidden" name="token" value="231649c6-3627-4a7c-b1e0-20da6cad93d6" />
		  <div class="layui-form-item">
		    <label class="layui-form-label">用户名</label>
		    <div class="layui-input-inline">
		      <input type="text" id="loginName" name="loginName" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">密码</label>
		    <div class="layui-input-inline">
		      <input type="password" id="pwd" name="pwd" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">邮箱</label>
		    <div class="layui-input-inline">
		      <input type="text" id="email" name="email" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">手机号</label>
		    <div class="layui-input-inline">
		      <input type="text" id="mtel" name="mtel" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <div class="layui-input-block">
		      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
		      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		    </div>
		  </div>
		</form>
		 
		<script>
		//layui.use加载模块(组件)
  		layui.use(['form','jquery','layer'], function(){
		  //声明变量,存储模块,以便使用模块时通过变量名来调用
		  var form = layui.form;
		  var $ = layui.jquery;
		  var layer = layui.layer;
		  //监听由lay-filter值为formDemo的按钮触发的提交
		  form.on('submit(formDemo)', function(data){//匿名函数在按钮点击时执行
			//data.elem:代表的是点击的按钮
			//data.field:代表表单的数据
			//data.form:代表按钮所在的整个表单
			//console.log(data);
		    $.post(
				'http://stuapi.ysd3g.com/api/CreateUser',//请求地址
				data.field,//请求参数
				function(res){//回调函数,当请求返回200 ok时执行
					if(res.success){
						layer.msg('操作成功');
					}else{
						layer.msg('操作失败 ');
					}
				},'json'
			);
		    return false;//阻止表单提交
		  });
		});
		</script>
	</body>
</html>
